package com.example.demo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum DBConnectionTypeEnum {
    MySQL_CONNECTION_TYPE("com.mysql.jdbc.Driver", 1),
    SQLITE_CONNECTION_TYPE("", 2);

    private String value;
    private Integer type;


    /**
     * int类型转换成枚举类型
     *
     * @param type 对应枚举的int 类型
     * @return 返回枚举数据
     */

    public static DBConnectionTypeEnum valueOfType(int type) {
        switch (type) {
            case 1:
                return MySQL_CONNECTION_TYPE;
            case 2:
                return SQLITE_CONNECTION_TYPE;
            default:
                return null;
        }

    }

    public static String stringOfType(int type) {
        switch (type) {
            case 1:
                return MySQL_CONNECTION_TYPE.getValue();
            case 2:
                return SQLITE_CONNECTION_TYPE.getValue();
            default:
                return null;
        }
    }
}
